<?php
class search_listModel extends baseModel{

    //列表
    public function search_list($where,$limit,$model) {
        if($model==2){
        $sql="
            SELECT A.*,B.name as cname,B.subname as csubname,B.mid,C.content
            FROM {$this->model->pre}content A 
            INNER JOIN {$this->model->pre}category B ON A.cid = B.cid
            INNER JOIN {$this->model->pre}content_data C ON C.aid = A.aid
            WHERE {$where} ORDER BY A.updatetime DESC,A.aid DESC LIMIT {$limit}
            ";
        }else{
        $sql="
            SELECT A.*,B.name as cname,B.subname as csubname,B.mid
            FROM {$this->model->pre}content A 
            INNER JOIN {$this->model->pre}category B ON A.cid = B.cid
            WHERE {$where} ORDER BY A.updatetime DESC,A.aid DESC LIMIT {$limit}
            ";
        }
        $data=$this->model->query($sql);
        return $data;
    }

    public function search_count($where,$model) {
        if($model==2){
        $sql="
            SELECT count(*) as num
            FROM {$this->model->pre}content A 
            INNER JOIN {$this->model->pre}category B ON A.cid = B.cid
            INNER JOIN {$this->model->pre}content_data C ON C.aid = A.aid
            WHERE {$where}
            ";
        }else{
        $sql="
            SELECT count(*) as num
            FROM {$this->model->pre}content A 
            INNER JOIN {$this->model->pre}category B ON A.cid = B.cid
            WHERE {$where}
            ";
        }
        $data=$this->model->query($sql);
        return $data[0]['num'];
    }


}
